Page({
  data: {
    planId: '',
    planData: null
  },

  onLoad: function(options) {
    if (options.id) {
      this.setData({
        planId: options.id
      });
      this.loadPlanData(options.id);
    }
  },

  // 加载计划数据
  loadPlanData: function(planId) {
    // 模拟加载计划数据
    const planData = {
      id: planId,
      name: '我的阅读计划',
      type: 'collection',
      dailyCount: 2,
      reviewSchedule: '3',
      collections: [
        {
          id: '1',
          name: '初级绘本集',
          bookCount: 10
        },
        {
          id: '2',
          name: '动物主题绘本集',
          bookCount: 12
        }
      ],
      estimatedDailyCount: 8,
      totalBooks: 22,
      estimatedDays: 11
    };

    this.setData({
      planData: planData
    });
  },

  // 开始计划
  onStartPlan: function() {
    wx.showToast({
      title: '计划已开始',
      icon: 'success'
    });

    // 跳转到阅读页面或计划详情页
    setTimeout(() => {
      wx.navigateBack({
        delta: 2
      });
    }, 1500);
  },

  // 编辑计划
  onEditPlan: function() {
    wx.navigateBack();
  },

  // 返回上一页
  onBack: function() {
    wx.navigateBack();
  }
}); 